package commands;

import nanoxml.XMLElement;
import utils.ITransmittable;

/**
 * This command represents a request for the name of the 
 * player who isn't the table's owner.
 */
public class CommandOtherPlayerName implements ITransmittable
{
    private final static String ATTR_OTHER_PLAYER_NAME = "OtherPlayerName";
    private final static String ATTR_TABLE_NUM = "TableNum";
    
    private String otherPlayerName = null;
    private int tableNum;

    
    public CommandOtherPlayerName (String otherPlayerName, int tableNum)
    {
    	this.otherPlayerName = otherPlayerName;
    	this.tableNum = tableNum;
    }
    
	public CommandOtherPlayerName (XMLElement message)
    {
		otherPlayerName = (String) message.getAttribute(ATTR_OTHER_PLAYER_NAME);
    	tableNum = message.getIntAttribute(ATTR_TABLE_NUM);
    }


	@Override
	public XMLElement toXML()
	{
		XMLElement element = new XMLElement();
		
		element.setName(Commands.OTHER_PLAYER_NAME);
		element.setAttribute(ATTR_OTHER_PLAYER_NAME, otherPlayerName);
		element.setIntAttribute(ATTR_TABLE_NUM, tableNum);
		
		return element;
	}

	public String getOtherPlayerName()
	{
		return otherPlayerName;
	}
	
	public int getTableNum()
	{
		return tableNum;
	}
}
